"Программа позволяет копировать из Excel таблицы чисел.
Каждая строка таблицы предстваляется в виде списка чисел.

Чтобы воспользоваться программой нужно выделить ячейки,
скопировать их, после чего вызвать команду ImportListsFromExcel

Когда мы копируем ячейки в буфер обмена, в нём появляется 
текстовое представления таблицы. Функция parse превращает эту
строку в список списков чисел.
"

(setq else t)

(defun println (some)
  (princ some)
  (princ "\n"))

(defun delete (obj lst / res)
  (setq res '())
  (foreach elm lst
    (if (not (equal elm obj))
      (setq res 
            (cons elm res))))
  (reverse res))

(defun delete-last-nil (lst)
  (cond 
    ((and (null (first lst))
          (null (rest lst)))
     nil)
    ((null lst)
     nil)
    (else
     (cons (first lst)
           (delete-last-nil (rest lst))))))

(defun char->number (char)
  (- char 48))

(defun add-digit (num digit)
  (+ (* num 10)
     digit)) ; Добавляет цифру в правую часть числа

(defun add-char-digit (num char)
  (add-digit num
            (char->number char)))

(defun make-float (num div)
  (/ num (expt 10.0 div)))

(defun space-p (char)
  (or (= char (ascii " "))
      (= char (ascii "\t"))))

(defun new-line-p (char)
  (= char (ascii "\n")))

(defun digit-p (char)
  (and (numberp char)
       (<= (ascii "0")
           char
           (ascii "9"))))

(defun separator-p (char)
  (or (= char (ascii "."))
      (= char (ascii ","))))

(defun dot-p (char)
  (= char (ascii ".")))

(defun first (lst)
  (car lst))

(defun rest (lst)
  (cdr lst))

(defun end (numbers result)
  (reverse (cons (reverse numbers)
                    result)))

(defun in-fractional (chars result numbers num divisor / char)
  (setq char (first chars))
  (cond 
    ((space-p char)
     (in-space
       (rest chars)
       result
       (cons (make-float num divisor)
             numbers)))
    ((new-line-p char)
     (in-space
       (rest chars)
       (cons (reverse (cons (make-float num divisor) 
                            numbers))
             result)
       '()))
    ((digit-p char)
     (in-fractional
       (rest chars)
       result
       numbers
       (add-char-digit num char)
       (+ divisor 1)))
    ((null char)
     (end (cons num numbers)
          result))))

(defun in-whole (chars result numbers num / char)
  (setq char (first chars))
  (cond 
    ((space-p char)
     (in-space
       (rest chars)
       result
       (cons num numbers)))
    ((digit-p char)
     (in-whole
       (rest chars)
       result
       numbers
       (add-char-digit num char)))
    ((new-line-p char)
     (in-space
       (rest chars)
       (cons (reverse (cons num numbers))
             result)
       '()))
    ((separator-p char)
     (in-fractional
       (rest chars)
       result
       numbers
       num
       0))
    ((null char)
     (end (cons num numbers)
          result))))

(defun in-space (chars result numbers / char)
  (setq char (first chars))
  (cond
    ((space-p char)
     (in-space (rest chars)
               result
               numbers))
    ((digit-p char)
     (in-whole 
       (rest chars)
       result
       numbers
       (char->number char)))
    ((null char)
     (end numbers result))))

(defun parse (string)
  (in-space 
    (delete (ascii "\r") (vl-string->list string))
    '()
    '()))

(defun get-clipboard-text (/ result)
  (vlax-invoke 
    (vlax-get
      (vlax-get
        (vlax-create-object "htmlfile")
        'ParentWindow)
      'ClipBoardData)
    'GetData
    "Text"))

(defun c:ImportListsFromExcel (/ data)
  (setq data (get-clipboard-text))
  (delete-last-nil (parse data)))